import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/folder_list_entity.dart';

FolderListEntity $FolderListEntityFromJson(Map<String, dynamic> json) {
  final FolderListEntity folderListEntity = FolderListEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    folderListEntity.total = total;
  }
  final List<FolderData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<FolderData>(e) as FolderData).toList();
  if (data != null) {
    folderListEntity.data = data;
  }
  return folderListEntity;
}

Map<String, dynamic> $FolderListEntityToJson(FolderListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension FolderListEntityExtension on FolderListEntity {
  FolderListEntity copyWith({
    int? total,
    List<FolderData>? data,
  }) {
    return FolderListEntity()
      ..total = total ?? this.total
      ..data = data ?? this.data;
  }
}

FolderData $FolderDataFromJson(Map<String, dynamic> json) {
  final FolderData folderData = FolderData();
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    folderData.caseId = caseId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    folderData.name = name;
  }
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    folderData.createdAt = createdAt;
  }
  return folderData;
}

Map<String, dynamic> $FolderDataToJson(FolderData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseId'] = entity.caseId;
  data['name'] = entity.name;
  data['createdAt'] = entity.createdAt;
  return data;
}

extension FolderDataExtension on FolderData {
  FolderData copyWith({
    String? caseId,
    String? name,
    int? createdAt,
  }) {
    return FolderData()
      ..caseId = caseId ?? this.caseId
      ..name = name ?? this.name
      ..createdAt = createdAt ?? this.createdAt;
  }
}